<?
  if($_COOKIE["codiceUtente"]!=1)
      header("Location:../portal/manageErrors.php?lista=29*");
  else
  {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Nuovo utente</title>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/prototype.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/scriptaculous/effects.js" type="text/javascript"></script>
        <script src="../glassboxLatest/glassbox.2.0.0/javascripts/glassbox/glassbox.js" type="text/javascript"></script>

        <?php
        require_once  '../classes/DisciplinaManager.php';
        require_once  '../classes/ConnectionDB.php';
        $db =ConnectionDB::getInstance()->connectToDB();
        $result = DisciplinaManager::getInstance()->getDiscipline($db);
        ?>
        <style>
            @import url("../css/style.css");


            #userBox {
                padding-top: 5%;
            }

            #userBoxCont
            {
                padding-top: 3%;
                padding-left: 15%;
            }
            #myBox_contentBoxBg {
                background: url(../images/sfondoContainer.jpg );
                background-color :  #5767ab;
                filter: alpha(opacity=50);
                -moz-opacity:.50;
                opacity:.50;
            }
            #myBox{
                display: none;
            }
            #myBox_content {
                background: url(../images/sfondoContainer.jpg );
                background-color :  #5767ab;
                padding: 20px;
            }
            #myBox h3 {
                font-size: 17px;
                margin: 0px;
                text-align: center
            }

            #inserito
            {
                padding-top: 19px;
                font-size: 14px;
                display: none;
                color: #35ec17;
            }


        </style>
        <script type="text/javascript">
            path_to_root_dir = "../glassboxLatest/glassbox.2.0.0/";
            window.onload = function(){

                var userBox = new GlassBox();
                userBox.init( 'userBox', '620px', '310px', 'hidden','',true, false);
                userBox.ipos();
                userBox.appear();

            }

            function xXMLHttpRequest()
            {

                var client = null;
                if (window.XMLHttpRequest)
                {
                    client=new XMLHttpRequest();
                }
                // code for IE
                else if (window.ActiveXObject)
                {
                    client=new ActiveXObject("Microsoft.XMLHTTP");
                }

                return client;
            }


            function handler() {
                if(this.readyState == 4 && this.status == 200)
                {
                    if(this.responseText.indexOf("*")!=-1)
                        location.href="../portal/manageErrors.php?lista="+this.responseText;
                    else
                        document.getElementById('inserito').style.display="block";


                } else if (this.readyState == 4 && this.status != 200) {
                    // fetched the wrong page or network error...
                    alert("error this.status : " + this.status );

                }
            }

            function submitForm()
            {
                var client = xXMLHttpRequest();
                client.onreadystatechange = handler;

                var active = 0;
                if(document.getElementById('attivo').checked)
                    active=1;
                var param = "attivo="+ active +
                    "&username="+document.getElementById('username').value +
                    "&password="+document.getElementById('password').value +
                    "&nome="+document.getElementById('nome').value +
                    "&cognome="+document.getElementById('cognome').value +
                    "&email="+document.getElementById('email').value;

                client.open("POST", "nuovoOperatoreListener.php", true);
                client.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

                client.send(param);

            }




        </script>

    </head>

    <body>
        <?php include '../portal/header.php';?>

        <center>
            <div id="inserito" ><b>Utente correttamente inserito</b></div>
            <div id="userBox">

                <div id="userBoxCont">
                    <b><div style="color: red">I campi contrassegnati con "*" sono obbligatori.</div></b><br />
                    <table width="100%">
                        <input type="hidden" name="attivo" value="0"/>

                        <tr>
                            <td><strong>Attivo :</strong> </td>
                            <td><input type="checkbox" name="attivo" id="attivo"/></td>
                        </tr>
                        <tr>
                            <td><strong>Username* :</strong></td>
                            <td><input type="text" name="username" id="username" /></td>
                        </tr>
                        <tr>
                            <td><strong>Password* :</strong> </td><td><input type="password" name="password" id="password"/></td>
                        </tr>
                        <!--
                        <tr>
                            <td><strong>Discipline :</strong> </td>
                            <td><img src='../images/icons/PNG/My Documents.png' height='30' width='30' title='Discipline' border='0' onclick="javascript:location.href='disciplineUtente.php'"/></td>

                        </tr>
                        -->
                        <tr>
                            <td><strong>Nome* :</strong> </td>
                            <td><input type="text" name="nome" id="nome"/></td>
                        </tr>
                        <tr>
                            <td><strong>Cognome* :</strong> </td><td><input type="text" name="cognome" id="cognome" /></td>
                        </tr>
                        <tr>
                            <td><strong>Email* :</strong> </td><td><input type="text" name="email" id="email" /></td>
                        </tr>
                        <tr>
                            <td><input type="button" value="Inserisci" onclick="javascript:submitForm()" /></td>


                        </tr>

                    </table>

                </div>
            </div>
        </center>
    </body>
</html>
<?}?>